/* Copyright (c) 2007 Pentaho Corporation.  All rights reserved. 
 * This software was developed by Pentaho Corporation and is provided under the terms 
 * of the GNU Lesser General Public License, Version 2.1. You may not use 
 * this file except in compliance with the license. If you need a copy of the license, 
 * please go to http://www.gnu.org/licenses/lgpl-2.1.txt. The Original Code is Pentaho 
 * Data Integration.  The Initial Developer is Pentaho Corporation.
 *
 * Software distributed under the GNU Lesser Public License is distributed on an "AS IS" 
 * basis, WITHOUT WARRANTY OF ANY KIND, either express or  implied. Please refer to 
 * the license for the specific language governing your rights and limitations.*/

package com.dc.trans.steps.datapack;

import java.sql.PreparedStatement;
import java.sql.Savepoint;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Hashtable;
import java.util.List;
import java.util.Map;

import org.pentaho.di.core.RowSet;
import org.pentaho.di.core.database.DatabaseMeta;
import org.pentaho.di.core.row.RowMetaInterface;
import org.pentaho.di.core.row.ValueMetaInterface;
import org.pentaho.di.trans.step.BaseStepData;
import org.pentaho.di.trans.step.StepDataInterface;

import com.dc.di.exchange.database.ExDatabase;
import com.dc.di.sf.dt.DataStructure;
import com.dc.di.sf.dt.MessageConvertInterface;

/**
 * @author Matt
 * @since 24-jan-2005
 */
public class DataPackData extends BaseStepData implements StepDataInterface {

	public ExDatabase db;
	public int warnings;

	/**
	 * Mapping between the SQL and the actual prepared statement. Normally this
	 * is only one, but in case we have more then one, it's convenient to have
	 * this.
	 */
	public Map<String, PreparedStatement> preparedStatements;

	/** Use batch mode or not? */
	public boolean batchMode;

	public List<Object[]> batchBuffer;
	public boolean sendToErrorRow;
	public RowMetaInterface outputRowMeta;
	public RowMetaInterface insertRowMeta;
	public boolean specialErrorHandling;
	public Savepoint savepoint;

	public DatabaseMeta databaseMeta;

	public Map<String, Integer> commitCounterMap;
	
	public DataStructure dataStructure;
	public String dataStructureString;
	
	public Hashtable<Object, RowSet> outputMap;
	public Hashtable<Object, StringBuilder> outputStringMap;
	public Hashtable<Object, StringBuilder> outputAttMap;
	public Hashtable<Object, String> groupSnMap;
	public Hashtable<Object, Long> packNumMap;
	public Hashtable<Object, Long> packSizeLimitMap;
	public Hashtable<Object, Long> packDataCountMap;	
	
	public ValueMetaInterface valueMeta;
	public int fieldIndex;
	public int serviceFieldIndex;
	public int attFieldIndex;	
	public ValueMetaInterface inputValueMeta;
	public RowSet nullRowSet;
	public String lastSn;
	
	public String groupTableName;
	public String packTableName;

	public RowMetaInterface groupTableRowMeta;
	public RowMetaInterface packTableRowMeta;
	
	public MessageConvertInterface converter;
	
	public DataPackData() {
		super();

		db = null;
		warnings = 0;

		preparedStatements = new Hashtable<String, PreparedStatement>();

		batchBuffer = new ArrayList<Object[]>();
		commitCounterMap = new HashMap<String, Integer>();
		groupSnMap = new Hashtable<Object, String>();
		packNumMap = new Hashtable<Object, Long>();
		packSizeLimitMap = new Hashtable<Object, Long>();
		lastSn = null;

		nullRowSet = null;
		
		groupTableName = null;
		packTableName = null;
	}
}
